package com.servlet.user;

import com.enitiy.Kind;
import com.enitiy.User;
import com.service.kind.KindServiceImpl;
import com.service.user.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 创建作者 ：MySunshine
 * 创建时间 2022/10/24 16:49
 * 项目名称 SHUSHAN
 */
@WebServlet("/UserSelectByNumToUP")
public class UserSelectByNumToUP  extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String num = req.getParameter("num");
        UserServiceImpl usi = new UserServiceImpl();
        User user = usi.UserSelectByNum(Integer.parseInt(num));
        String img = user.getImg();
        if (img==null||img.length()<=0){
            img="1.jpg";
            user.setImg(img);
        }
        KindServiceImpl ksi = new KindServiceImpl();
        List<Kind> kinds = ksi.kindSelectAll();
        System.out.println(kinds);
        req.setAttribute("user",user);
        req.setAttribute("kinds",kinds);
        req.getRequestDispatcher("/page/user/userUpdate.jsp").forward(req,resp);
    }
}
